package com.meng.thrift.client.b_service;

import com.meng.thrift.client.common.*;
import com.meng.thrift.client.thrift.callback.UserService_getUserAsyncCallback;
import com.meng.thrift.client.thrift.inter.UserService;
import com.meng.thrift.client.thrift.util.GetThriftServerObj;
import com.meng.thrift.client.thrift.util.ThriftIpPortEnum;
import org.apache.thrift.TException;
import org.springframework.stereotype.Service;

import java.io.IOException;


/**
 * 测试service
 *
 * @author MENG
 * @version 2017/11/15
 * @see
 */
@Service
public class TestService
{

    public TestService()
    {
        System.out.println("TestService-----------------------------------------------扫描");
    }

    @GetThriftServerObj(ipPort = ThriftIpPortEnum.MENGLOCAL_IP_PORT_8191)
    private UserService.AsyncClient userService;

    public void test()
    {
        try
        {
            UserService_getUserAsyncCallback callback = new UserService_getUserAsyncCallback();

            userService.getUser(null,callback);
        }
        catch (TException e)
        {
            LoggerUtil.logger.error("Thrift 远程调用错误!",e);
        }
    }

    public static void main(String[] args)
    {

        try
        {
            //获取配置文件信息   这种目录结构读取配置文件和配置文件直接放在Src下 读取一样
            System.out.println(Utils.getPropertiesValByKey("url","mysql_db.properties"));
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }

}
